//
//  ShopCarBootomView.m
//  GLGW_Shoping
//
//  Created by yang on 2018/11/20.
//  Copyright © 2018年 yang. All rights reserved.
//

#import "ShopCarBootomView.h"

@implementation ShopCarBootomView{
    GLGWButton * bottomSelectBut;
    GLGWLabel * hejiLabel;
    GLGWLabel * combinedLabel;
}

-(id)initWithFrame:(CGRect)aFrame inSuperView:(UIView *)aSuperView{
    if (self = [super initWithFrame:aFrame inSuperView:aSuperView]) {
        self.backgroundColor = [UIColor whiteColor];
        GLGWView * lineView =[[GLGWView alloc] initWithInSuperView:self];
        lineView.backgroundColor = [UIColor colorWithHexString:@"#EAEAEA"];
        [lineView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.top.right.equalTo(self);
            make.height.equalTo(@1);
        }];
        bottomSelectBut = [[GLGWButton alloc] initWithFrame:CGRectMake(0, kHeightProportion_In_iPhoneTriploid(5), kWidthProportion_In_iPhoneTriploid(80), kHeightProportion_In_iPhoneTriploid(40)) titleLableFont:SYSTEMFONT(14) titleColor:kColor_Rule_Black inSuperView:self];
        bottomSelectBut.image_Name = @"icon_weixuanzhe";
        [bottomSelectBut setImage:[UIImage imageNamed:@"icon_xuanzhe_zhaopian"] forState:UIControlStateSelected];
        bottomSelectBut.title = @"全选";
        [bottomSelectBut setImagePositionWithType:SSImagePositionTypeLeft spacing:kWidthProportion_In_iPhoneTriploid(5)];
        [bottomSelectBut addTarget:self action:@selector(allSelect:) forControlEvents:UIControlEventTouchUpInside];
        //
        hejiLabel  = [[GLGWLabel alloc] initWithFrame:CGRectMake(kX_With_View(bottomSelectBut, 0), kHeightProportion_In_iPhoneTriploid(16), kWidthProportion_In_iPhoneTriploid(30), kHeightProportion_In_iPhoneTriploid(17)) theFont:SYSTEMFONT(12) theColor:[UIColor colorWithHexString:@"#666666"] inSuperView:self];
        hejiLabel.text = @"合计";
        //
        combinedLabel = [[GLGWLabel alloc] initWithFrame:CGRectMake(kX_With_View(hejiLabel, 3), kHeightProportion_In_iPhoneTriploid(13), self.width - kX_With_View(hejiLabel, 3) - kWidthProportion_In_iPhoneTriploid(120), kHeightProportion_In_iPhoneTriploid(22)) theFont:SYSTEMFONT(16) theColor:[UIColor colorWithHexString:@"#EC5353"] inSuperView:self];
        combinedLabel.text = @"￥0.00";
        //
        self.payBut = [[GLGWButton alloc] initWithTitle:@"去结算" titleLableFont:SYSTEMFONT(14) titleLableColor:[UIColor whiteColor] theCornerRadius:kHeightProportion_In_iPhoneTriploid(20) backgroundColr:kColor_Rule_Yellow inSuperView:self];
        [self.payBut mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(self.mas_top).offset(kHeightProportion_In_iPhoneTriploid(5));
            make.right.equalTo(self.mas_right).offset(-kWidthProportion_In_iPhoneTriploid(15));
            make.width.equalTo(@(kWidthProportion_In_iPhoneTriploid(100)));
            make.height.equalTo(@(kHeightProportion_In_iPhoneTriploid(40)));
        }];
        [self.payBut addTarget:self action:@selector(jieAction) forControlEvents:UIControlEventTouchUpInside];
    }
    return self;
}

-(void)allSelect:(GLGWButton *)sender{
    if (self.Block_AllSelectAction) {
        self.Block_AllSelectAction(sender);
    }
}

-(void)jieAction{
    if (self.Block_JieBottom) {
        self.Block_JieBottom();
    }
}

#pragma mark -- set
-(void)setAllSelectGoodsMoney:(CGFloat)allSelectGoodsMoney{
    _allSelectGoodsMoney = allSelectGoodsMoney;
    combinedLabel.text = [NSString stringWithFormat:@"%.2f",_allSelectGoodsMoney];
}

-(void)setAllGoodsBool:(BOOL)allGoodsBool{
    _allGoodsBool = allGoodsBool;
    bottomSelectBut.selected = _allGoodsBool;
}
-(void)setEditIsBool:(BOOL)editIsBool{
    _editIsBool = editIsBool;
    if (_editIsBool) {
        combinedLabel.hidden = YES;
        hejiLabel.hidden = YES;
        self.payBut.title = @"删除";
        self.payBut.image_Name = @"icon_shanchu";
        [self.payBut setImagePositionWithType:SSImagePositionTypeLeft spacing:kWidthProportion_In_iPhoneTriploid(5)];
        self.payBut.backgroundColor = [UIColor whiteColor];
        [self.payBut setTitleColor:kColor_Rule_Black forState:UIControlStateNormal];
        [UIView animateWithDuration:0.25 animations:^{
            [self.payBut mas_updateConstraints:^(MASConstraintMaker *make) {
                make.right.equalTo(self.mas_right).offset(0);
                make.width.equalTo(@(kHeightProportion_In_iPhoneTriploid(90)));
            }];
            [self.superview layoutIfNeeded];//强制绘制
        }];
    }else{
        combinedLabel.hidden = NO;
        hejiLabel.hidden = NO;
        self.payBut.backgroundColor = kColor_Rule_Yellow;
        self.payBut.image_Name = @"oo";
        [self.payBut setImagePositionWithType:SSImagePositionTypeLeft spacing:0];
        [self.payBut setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
        [UIView animateWithDuration:0.25 animations:^{
            [self.payBut mas_updateConstraints:^(MASConstraintMaker *make) {
                make.right.equalTo(self.mas_right).offset(-kWidthProportion_In_iPhoneTriploid(15));
                make.width.equalTo(@(kWidthProportion_In_iPhoneTriploid(100)));
            }];
            [self.superview layoutIfNeeded];//强制绘制
        }];
    }
}
@end
